package Class_04_07;

import Class_03_15.Fruit;

import java.util.Scanner;

//定义接口
interface fruit
{

}

class apple implements fruit
{
    public apple()
    {
        System.out.println("创建了一个苹果类的对象");
    }
}

class banana implements fruit
{
    public banana()
    {
        System.out.println("创建了一个香蕉类的对象");
    }
}

class grape implements fruit
{
    public grape()
    {
        System.out.println("创建了一个葡萄类的对象");
    }
}

public class Main4 {
    static fruit JudgeFruit(String Fname)
    {
        fruit f = null;
        if("apple".equals(Fname))
        {
            f = new apple();
        }
        if("banana".equals(Fname))
        {
            f = new banana();
        }
        if("grape".equals(Fname))
        {
            f = new grape();
        }
        return f;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入水果名");
        String Fname = sc.next();
        fruit f = JudgeFruit(Fname);
    }
}
